package com.itheima.search.controller;
import com.itheima.common.pojo.Result;
import com.itheima.search.pojo.ApUserSearch;
import com.itheima.search.service.ApUserSearchService;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.itheima.core.controller.AbstractCoreController;

import java.util.List;

/**
* <p>
* APP用户搜索信息表 控制器</p>
* @author 作者
* @since 2021-09-02
*/
@RestController
@RequestMapping("/apUserSearch")
public class ApUserSearchController extends AbstractCoreController<ApUserSearch> {

    private ApUserSearchService apUserSearchService;

    //注入
    @Autowired
    public ApUserSearchController(ApUserSearchService apUserSearchService) {
        super(apUserSearchService);
        this.apUserSearchService=apUserSearchService;
    }

    /***
     * 删除关键词
     */
    @DeleteMapping(value = "/{keyword}")
    public Result delete(@PathVariable(value = "{keyword}")String keyword){
        apUserSearchService.deleteUserSearchWord(keyword);
        return Result.ok();
    }

    /***
     * 用户搜索关键词列表
     */
    @GetMapping(value = "/list")
    public Result list(){
        List<ApUserSearch> lists = apUserSearchService.searchList();
        return Result.ok(lists);
    }

}

